<script setup lang="ts">
// const props = withDefaults(defineProps<{
//   name: string;
//   age?: number;
//   func?(count:number): void
// }>(),{
//     name:'默认值',
//     age:100
// })
const {age = 10} = defineProps<{
  name: string;
  age?: number;
  func?(count:number): void
}>();
const emits = defineEmits<{
    "updateAge":[age:number],
    "updateName" : [name:string],
    "updateAll" : [age: number,name:string]
}>()
const toParent = ()=>{
    emits("updateAge",age - 1)
}
</script>

<template>
  <div>
    <p>子组件的姓名：{{ name }}</p>
    <p>子组件的年龄：{{ age }}</p>
    <button @click="func(age - 1 )">子传父 - 回调函数形式</button>
    <button @click="toParent">子传父 - emits形式</button>

  </div>
</template>

<style scoped></style>
